package com.googlecode.payroll

class SalesAmountTotalizer {

    private static final int TOTAL_AMOUNT = 0
    private static final int EMPLOYEE_ID = 1

    def salesAmountOf(final empId) {

        // FIXME Having trouble when arraysize is 0
        try {
            size()
        } catch(MissingMethodException e) {
            return 0
        }

        for ( it in this ) {
            if (empId == it[EMPLOYEE_ID]) {
                return it[TOTAL_AMOUNT]
            }
        }
        0
    }
}
